package com.example.springboot_redis_01_test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.Assert;

@SpringBootApplication
public class SpringBootRedis01TestApplication {

    public SpringBootRedis01TestApplication(RedisTemplate<String, String> redisTemplate) {
        redisTemplate.opsForValue().set("hello", "world");
        String ans = null;
        try {
            ans = redisTemplate.opsForValue().get("hello");
            Assert.isTrue("world".equals(ans),"redis没有正常使用！");
        } catch (Exception e) {
            System.out.println("获取Redis值失败： " + e.getMessage());
        }
    }

    public static void main(String[] args) {
        SpringApplication.run(SpringBootRedis01TestApplication.class, args);
    }
}
